package org.example.jdk8.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;

public class test2 {
    public static void main(String[] args) {

        Stream<String> stream = Stream.of("hello", "world", "java");
//        stream.toArray(String[]::new);
//        List<String> list = stream.collect(()->new ArrayList(),(theList, item)->theList.add(item),(theList1, theList2)->theList1.addAll(theList2));
//        stream.collect(ArrayList::new,List::add,List::addAll).forEach(System.out::println);

//        list.forEach(System.out::println);

        /*stream.map(String::toUpperCase).forEach(System.out::println);

        System.out.printf( UUID.randomUUID().toString());*/

        /*Stream.iterate(1,item ->item +2).limit(6).filter(item->item>2)
                .map(item->item*2).skip(2).limit(2).forEach(System.out::println);*/

        /*Stream.iterate(1,item ->item +2).limit(6)
                .filter(item->item>2).map(item->item*2)
                .skip(2).limit(2)
                .reduce((a,b)-> a+b).ifPresent(System.out::println);*/

        /*System.out.println(Stream.iterate(1, item -> item + 2).limit(6)
                .filter(item -> item > 2).mapToInt(item -> item * 2)
                .skip(2).limit(2).sum());*/

        /*Stream.iterate(1, item -> item + 2).limit(6)
                .filter(item -> item > 200).mapToInt(item -> item * 2)
                .skip(2).limit(2).max().ifPresent(System.out::println);*/

        System.out.println(Stream.iterate(1, item -> item + 2).limit(6)
                .filter(item -> item > 2).mapToInt(item -> item * 2)
                .skip(2).limit(2).summaryStatistics().getMin());
    }

}
